#ifndef SERVERWINDOW_H
#define SERVERWINDOW_H

#include <QMainWindow>
#include <QtNetwork>
#include <QPushButton>
#include <QLabel>
#include <QPlainTextEdit>
#include "server.h"

namespace Ui {
class ServerWindow;
}
/**
 * 服务端窗口
 * @brief The ServerWindow class
 */
class ServerWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit ServerWindow(QWidget *parent = nullptr);
    void init();
    ~ServerWindow();

public slots:
    //开启服务端
    void startServer();
    //停止服务端
    void stopServer();
    //发送消息
    void slotSendMsg();
    //收到新连接
    void slotNewConnection(QString client);
    //收到消息
    void slotReceiveMsg(QString client, QString msg);
    //连接断开
    void slotDisConnection(QString client);
private:
    Server * server = nullptr;
    Ui::ServerWindow *ui;
    //开启服务端
    QPushButton * startServerBtn;
    //停止服务端
    QPushButton * stopServerBtn;
    QLabel * label;
    QPlainTextEdit * textEdit;

    QLabel * receiveMsgLabel;
    QPlainTextEdit * receiveTextEdit;

    QLabel * sendMsgLabel;
    QPlainTextEdit * sendTextEdit;

    QPushButton * sendBtn;




};

#endif // SERVERWINDOW_H
